package com.gitee.zycra.union.api.service;

import com.gitee.zycra.union.api.common.bo.CommonResult;
import com.gitee.zycra.union.api.manager.ApiProjectGroupManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author zycra
 */
@Slf4j
@Service
public class ApiProjectGroupService {

    @Autowired
    private ApiProjectGroupManager apiProjectGroupManager;

    /**
     * 添加项目组
     *
     * @param groupName 项目组名称
     * @return 添加结果
     */
    public CommonResult<String> addGroup(String groupName) {
        apiProjectGroupManager.addGroup(groupName);
        return CommonResult.success();
    }

    /**
     * 根据ID更新项目组
     *
     * @param id        项目组ID
     * @param groupName 项目组名称
     * @return 更新条数
     */
    public CommonResult<String> updateGroup(Long id, String groupName) {
        apiProjectGroupManager.updateGroup(id, groupName);
        return CommonResult.success();
    }

    /**
     * 根据ID删除项目组
     *
     * @param id 项目组ID
     * @return 删除条数
     */
    public CommonResult<String> deleteGroup(Long id) {
        apiProjectGroupManager.deleteGroup(id);
        return CommonResult.success();
    }
}
